using System;
using System.Collections.Generic;
using Dict.DataModel;

namespace Dict.Dao
{
    public class TableHeroTrainingMaxMinDao:DaoBase<TableHeroTrainingMaxMin>
    {
        public override void AddPrimaryIndex(TableHeroTrainingMaxMin model)
        {
            cachePrimary[model.id.ToString()] = model;
        }

        public override string GetFileName()
        {
            return "TableHeroTrainingMaxMin.txt";
        }

        protected override TableHeroTrainingMaxMin ParseRowData(string[] rowData)
        {
            TableHeroTrainingMaxMin data = new TableHeroTrainingMaxMin();

            if (string.IsNullOrEmpty(rowData[0]))
            {
                data.id = 0;
            }
            else
            {
                data.id = int.Parse(rowData[0]);
            }
			data.warId = rowData [1];

            if (string.IsNullOrEmpty(rowData[2]))
            {
                data.warLv = 0;
            }
            else
            {
                data.warLv = int.Parse(rowData[2]);
            }

            if (string.IsNullOrEmpty(rowData[3]))
            {
                data.attMax = 0;
            }
            else
            {
                data.attMax = int.Parse(rowData[3]);
            }

            if (string.IsNullOrEmpty(rowData[4]))
            {
                data.hpMax = 0;
            }
            else
            {
                data.hpMax = int.Parse(rowData[4]);
            }

            if (string.IsNullOrEmpty(rowData[5]))
            {
                data.mdefMax = 0;
            }
            else
            {
                data.mdefMax = int.Parse(rowData[5]);
            }

            if (string.IsNullOrEmpty(rowData[6]))
            {
                data.pdefMax = 0;
            }
            else
            {
                data.pdefMax = int.Parse(rowData[6]);
            }

            return data;
        }



        public override void AddTwoIndex(TableHeroTrainingMaxMin model)
        {
            string key = GetUnionKey(model.warId.ToString(),model.warLv.ToString());
            if (!cacheTwoIndex.ContainsKey(key))
            {
                cacheTwoIndex[key] = new List<TableHeroTrainingMaxMin>();
            }
            cacheTwoIndex[key].Add(model);
        }


    }

}
